<div class="faculty-committee">
	<div class="view">
        <div class="container-fluid">

            <div class="row-fluid">
                <div class="span12">
                    <?php
                        echo form_open('committee/update',
                            array(
                                'id' => 'frm_save_committee'
                            )
                        );
                    ?>
                    <form style="font-family:Georgia; font-size:18px; font-weight:bold; color:#00F">
                    <center>
                             <legend>Faculty Committee</legend>
                             <label>Faculty Area Head</label>
                        <select id="faculty-head" name="input-areahead">
                            <option value="null"></option>
                            <?php
                            foreach($profiles as $profile)
                            {
                                $option = $profile['LastName'].", "
                                    .$profile['MiddleName']." ".$profile['FirstName'];
                                echo "<option id ='".$profile['MemberID']."' value='".$profile['MemberID']."'>".$option."</option>";
                            }
                            ?>
                        </select>
                             
                    <div class="row-fluid">
                        <div class="span12">
                             <label>Faculty Area Head Assistant</label>
                            <select id="faculty-assist" name="input-assistant">
                                <option value="null"></option>
                                <?php
                                foreach($profiles as $profile)
                                {
                                    $option = $profile['LastName'].", "
                                        .$profile['MiddleName']." ".$profile['FirstName'];
                                    echo "<option id ='".$profile['MemberID']."' value='".$profile['MemberID']."'>".$option."</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                        <label>Secretary</label>
                            <select id="secretary" name="input-secretary"  >
                                <option value="null"></option>
                                <?php
                                foreach($profiles as $profile)
                                {
                                    $option = $profile['LastName'].", "
                                        .$profile['MiddleName']." ".$profile['FirstName'];
                                    echo "<option id ='".$profile['MemberID']."' value='".$profile['MemberID']."'>".$option."</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    
                    <div class="row-fluid">
                        <div class="span12">
                             <label>Treasurer</label>
                            <select id="treasurer" name="input-treasurer">
                                <option value="null"></option>
                                <?php
                                foreach($profiles as $profile)
                                {
                                    $option = $profile['LastName'].", "
                                        .$profile['MiddleName']." ".$profile['FirstName'];
                                    echo "<option id ='".$profile['MemberID']."' value='".$profile['MemberID']."'>".$option."</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    
                    <br/>
                    

                    
                            <button id = "btn_save_committee" type="button" class="btn-info">SAVE</button>
                            <button id = "btn_cancel_committee" type="button" class="btn-info">CANCEL</button>
                        </center>
                        <input type="hidden" id = "id_list" name="input_id_list">
                    </form>
                </div>
            </div>
        </div>
	</div>
</div>



<script type = 'text/javascript'>
    $('#btn_addMember').click(
        function(){
            selectedOption = $('#members option:selected');
            nameToAdd = selectedOption.html();
            if(nameToAdd!=null)
            {
                attendees = $('#member_fields')
                attendees.html(attendees.html() +
                    "<option id='"+selectedOption.attr('id')+"'>"
                    + selectedOption.html() +
                    "</option>");
                selectedOption.remove();
            }
        }
    )

    $('#btn_removeMember').click(
        function(){
            selectedOption = $('#member_fields option:selected');
            nameToAdd = selectedOption.html();
            if(nameToAdd!=null)
            {
                attendees = $('#members')
                attendees.html(attendees.html() +
                    "<option id='"+selectedOption.attr('id')+"'>"
                    + selectedOption.html() +
                    "</option>");
                selectedOption.remove();
            }
        }
    )

    $('#btn_save_committee').click(

        function(){
            var options = $('#member_fields').find('option');
            id_list = "";
            ctr = 0;
            for(ctr = 0; ctr<options.length; ctr++){
                id_list+=options[ctr].id + " ";
            }
            $('#id_list').val(id_list);
            $('#frm_save_committee').submit();
        }
    )

    $('#btn_cancel_committee').click(
        function(){
            window.location = 'view';
        }
    )
</script>
